Skip to content

Add configure connection list subcommand#24

Merged
ewega merged 2 commits intomainfrom
copilot/add-configure-connection-list
Feb 19, 2026
Merged

Add configure connection list subcommand#24
ewega merged 2 commits intomainfrom
copilot/add-configure-connection-list

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 19, 2026

Adds a read-only list subcommand under configure connection to enumerate all existing DevLake plugin connections — useful for scripting, debugging, and auditing what's configured.

Changes

  • cmd/configure_connection_list.go — new list subcommand:

    • Iterates all available plugins (or the single --plugin arg) and calls GET /plugins/{plugin}/connections
    • Renders tab-aligned table via text/tabwriter: Plugin · ID · Name · Organization · Enterprise
    • --plugin validates against available (non-coming-soon) plugins, matching the error pattern from other commands
    • Per-plugin API errors are non-fatal (⚠️ warning, continues to next plugin)
    • Prints "No connections found." when the result set is empty
  • cmd/configure_connection_list_test.go — covers unknown plugin rejection, availablePluginSlugs correctness, and subcommand registration

  • README.md — documents the new subcommand with flag table and example output

Usage

gh devlake configure connection list
gh devlake configure connection list --plugin gh-copilot
Plugin       ID  Name                     Organization  Enterprise
──────────   ──  ───────────────────────  ────────────  ──────────
github        1  GitHub - my-org          my-org
gh-copilot    2  Copilot - my-org         my-org        avocado-corp
Original prompt

This section details on the original issue you should resolve

<issue_title>Add configure connection list command</issue_title>
<issue_description>## Summary
Add a \configure connection list\ subcommand to show all existing connections, useful for scripting, debugging, and answering 'what do I have?'.

Design

\
gh devlake configure connection list
gh devlake configure connection list --plugin gh-copilot # filter by plugin
\\

Output:
\
Plugin ID Name Organization Enterprise
github 1 GitHub - my-org my-org
gh-copilot 2 GitHub Copilot - my-org my-org avocado-corp
\\

Changes

  • Add \list\ subcommand under \configure connection\
  • Iterate all known plugins, call \GET /plugins/{plugin}/connections\
  • Optional --plugin\ filter
  • Table-formatted output

Acceptance Criteria

  • Lists connections from all available plugins
  • --plugin\ flag filters to one plugin
  • Shows ID, name, organization, enterprise columns
  • Clean output when no connections exist</issue_description>

<agent_instructions>IMPORTANT: Issues #5 and #6 just merged — commands are now singular (connection, scope, project) and use --plugin flag instead of --skip-* flags. Work off the latest main.

Key implementation points:

  1. Add a list subcommand under configure connection — this means adding it as a subcommand of configureConnectionsCmd in configure.go or creating a new file
  2. The command should be: gh devlake configure connection list [--plugin gh-copilot]
  3. Iterate all known plugins from connectionRegistry, call GET /plugins/{plugin}/connections via the existing client.ListConnections(plugin) method
  4. Optional --plugin flag to filter to one plugin
  5. Table-formatted output showing: Plugin, ID, Name, Organization, Enterprise columns
  6. Clean output when no connections exist
  7. Read AGENTS.md for project conventions and .github/instructions/terminal-output.instructions.md for UX/formatting rules
  8. Update README.md with the new command documentation
  9. Run go build ./... and go test ./... to verify</agent_instructions>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: ewega <26189114+ewega@users.noreply.github.com>
Copilot AI changed the title [WIP] Add configure connection list command Add configure connection list subcommand Feb 19, 2026
@ewega ewega requested a review from Copilot February 19, 2026 16:58
@ewega ewega marked this pull request as ready for review February 19, 2026 16:58
@ewega ewega merged commit 2901400 into main Feb 19, 2026
4 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new read-only CLI subcommand to enumerate existing DevLake plugin connections, primarily to help with inspection and automation.

Changes:

  • Introduces gh devlake configure connection list with optional --plugin filtering and tabular output.
  • Adds unit tests for plugin validation, available plugin slugs, and subcommand registration.
  • Documents the new subcommand in the README with usage and sample output.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
cmd/configure_connection_list.go Implements the new configure connection list command, plugin filtering/validation, and table rendering.
cmd/configure_connection_list_test.go Adds basic tests for validation helpers and command registration.
README.md Documents the new subcommand, flags, and example output.
Comments suppressed due to low confidence (5)

cmd/configure_connection_list.go:34

  • This command is described as useful for scripting, but it prints a large banner to stdout before the table. That makes configure connection list | ... harder to parse. Consider either removing the banner for this read-only command, or writing banners/progress messages to stderr so stdout remains just the tabular data (or "No connections found.").

This issue also appears in the following locations of the same file:

  • line 46
  • line 74
  • line 91
	fmt.Println()
	fmt.Println("════════════════════════════════════════")
	fmt.Println("  DevLake — List Connections")
	fmt.Println("════════════════════════════════════════")

cmd/configure_connection_list.go:52

  • The "Discovering DevLake" status lines are printed to stdout; for script-friendly output they should be suppressed or redirected to stderr (similar to how other commands write warnings to os.Stderr). Otherwise callers expecting only the table on stdout will get extra lines mixed in.
	fmt.Println("\n🔍 Discovering DevLake instance...")
	disc, err := devlake.Discover(cfgURL)
	if err != nil {
		return err
	}
	fmt.Printf("   Found DevLake at %s (via %s)\n", disc.URL, disc.Source)

cmd/configure_connection_list.go:77

  • Per-plugin API failures are currently reported with fmt.Printf to stdout. Because the command’s primary output is a table on stdout, warnings like this should go to stderr to avoid corrupting piped/tabular output.
		conns, err := client.ListConnections(def.Plugin)
		if err != nil {
			fmt.Printf("\n⚠️  Could not list %s connections: %v\n", def.DisplayName, err)
			continue

cmd/configure_connection_list.go:100

  • Output is split between fmt.Println (implicit stdout) and cmd.OutOrStdout() (tabwriter). This makes it impossible to reliably capture/redirect the command’s output via cobra (cmd.SetOut) and can interleave output on different writers. Prefer consistently writing user-facing output via cmd.OutOrStdout(), and send diagnostics to cmd.ErrOrStderr().
	fmt.Println()
	if len(rows) == 0 {
		fmt.Println("  No connections found.")
		fmt.Println()
		return nil
	}

	w := tabwriter.NewWriter(cmd.OutOrStdout(), 0, 0, 2, ' ', 0)
	fmt.Fprintln(w, "Plugin\tID\tName\tOrganization\tEnterprise")
	fmt.Fprintln(w, strings.Repeat("─", 10)+"\t"+strings.Repeat("─", 4)+"\t"+strings.Repeat("─", 30)+"\t"+strings.Repeat("─", 14)+"\t"+strings.Repeat("─", 12))

cmd/configure_connection_list.go:117

  • availablePluginSlugs() returns plugins in whatever order AvailableConnections() provides. That order is used in the "choose:" error message, so sorting the slugs would make the message deterministic and keep it consistent with other commands (typically "github, gh-copilot").
func availablePluginSlugs() []string {
	defs := AvailableConnections()
	slugs := make([]string, len(defs))
	for i, d := range defs {
		slugs[i] = d.Plugin
	}
	return slugs

@ewega ewega deleted the copilot/add-configure-connection-list branch March 2, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add configure connection list command

3 participants